package WaiBao;

import java.util.Arrays;

public class YangSanSan {
    public static void main(String[] args) {
        String[] name = {"张鹏伟(班长)", "李峰(副班长)", "小李(学习委员)", "王凯(体育委员)", "王俊玲(纪律委员)", "李成双", "高育良", "李达康", "田国富", "沙瑞金", "邱整数", "文装祥",
                "陈海", "刘康康", "王自力", "贺易", "李佳聪", "邱樊荣", "黄制样", "蔡蔡", "莫李恩", "郝秒", "梁成金", "何刚明", "莫须有", "严席华", "李康", "张柏芝",
                "陈阳", "杨珊珊(学生)"};//考生本人:杨珊珊(学生)
        int[] age = {20, 19, 19, 20, 20, 18, 21, 18, 19, 20, 20, 19, 18, 20, 21, 20, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 20, 20, 19, 20};//考生年龄：20

        double[] xiaohai1 = {85, 84, 84, 86, 78, 69, 74, 89, 80, 71, 91, 87, 85, 74, 75, 78, 69, 90, 91, 88, 92, 91, 75, 88, 70, 74, 78, 76, 81, 85};
        double[] xiaohai2 = {65, 77, 74, 84, 85, 77, 85, 74, 72, 80, 83, 78, 87, 75, 64, 64, 70, 74, 76, 68, 82, 74, 68, 80, 77, 85, 74, 85, 75, 83};
        double[] xiaohai3 = {76, 90, 71, 85, 71, 69, 78, 81, 84, 69, 93, 85, 85, 75, 64, 68, 69, 69, 96, 73, 92, 81, 90, 95, 79, 87, 75, 61, 74, 88};

        double word1;//代表每个学生的总分
        double word2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            word1 = xiaohai1[i] +xiaohai2[i] +xiaohai3[i];
//            word2 = ( word1* 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + word1);
//            System.out.println(name[i] + "的平均分为:" +word2);
//        }


//        double zhibo1 = 0,zhibo2 = 0;
//        double[] friend = new double[30];
//        for (int i = 0; i < 30; i++) {
//            zhibo1 = xiaohai1[i] + xiaohai2[i] +xiaohai3[i];
//            zhibo2 = (zhibo1 * 1.0) / 3;
//            friend[i] = zhibo2;
//        }
//
//        for (int i = 0; i <friend.length - 1; i++) {
//            for (int j = 0; j < friend.length - i - 1; j++) {
//                if (friend[j] < friend[j + 1]) {
//                    double tep = friend[j];
//                    friend[j] = friend[j + 1];
//                    friend[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(friend[i]);
//        }



        double yaoyao1 = 0,yaoyao2 = 0, yaoyao3 = 0;//计算每门课的平均分
        double saoyi1 = 0,saoyi2 = 0, saoyi3 = 0;//计算每门课标准差
        double gouwu1 = 0,gouwu2 = 0, gouwu3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i <xiaohai1.length; i++) {
            sum2+=xiaohai1[i];
        }
        yaoyao1 = (sum2*1.0)/30;
        System.out.println("生物化学的班级平均分为:"+yaoyao1);
        double Sum = 0;
        for (int i = 0; i <xiaohai2.length; i++) {
            Sum+=xiaohai2[i];
        }
        yaoyao2 = (Sum*1.0)/30;
        System.out.println("微生物学的班级平均分为:"+yaoyao2);
        double sum = 0;
        for (int i = 0; i <xiaohai3.length; i++) {
            sum+=xiaohai3[i];
        }
        yaoyao3 = (sum*1.0)/30;
        System.out.println("人体组织解剖学的班级平均分为:"+yaoyao3);



        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i <xiaohai1.length; i++) {
            c1+= (xiaohai1[i] -yaoyao1)*(xiaohai1[i] -yaoyao1);
        }
        saoyi1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:"+saoyi1);

        for (int i = 0; i < xiaohai2.length; i++) {
            c2+= (xiaohai2[i] -yaoyao2)*(xiaohai2[i] - yaoyao2);
        }
        saoyi2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:"+saoyi2);

        for (int i = 0; i <xiaohai3.length; i++) {
            c3+= (xiaohai3[i] -yaoyao3)*(xiaohai3[i] - yaoyao3);
        }
        saoyi3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:"+saoyi3);
////////////
////////////
        Arrays.sort(xiaohai1);
        Arrays.sort(xiaohai2);
        Arrays.sort(xiaohai3);
        gouwu1 =(xiaohai1[14]+xiaohai1[15])*1.0/2;
        gouwu2 =(xiaohai2[14]+xiaohai2[15])*1.0/2;
        gouwu3 =(xiaohai3[14]+xiaohai3[15])*1.0/2;
        System.out.println("生物化学的中位数为:"+gouwu1);
        System.out.println("微生物学的中位数为:"+gouwu2);
        System.out.println("人体组织解剖学的中位数为:"+gouwu3);


    }
}
